package ChainTable;


public class Test {
    //单链表测试
//    public static void main(String[] args) {
//        SingleLinkedList singleLinkedList = new SingleLinkedList();
//        singleLinkedList.addFirst(2);
//        singleLinkedList.addLast(3);
//        singleLinkedList.addLast(2);
//        singleLinkedList.addIndex(3,5);
//        singleLinkedList.addLast(2);
//        singleLinkedList.addLast(2);
//        System.out.println(singleLinkedList);
//        singleLinkedList.addLast(5);
//        System.out.println(singleLinkedList);
//        singleLinkedList.addIndex(2,10);
//        System.out.println(singleLinkedList);
//        singleLinkedList.removeFirst();
//        System.out.println(singleLinkedList);
//        singleLinkedList.removeIndex(2);
//        System.out.println(singleLinkedList);
//        singleLinkedList.removeValueOnce(2);
//        System.out.println(singleLinkedList);
//        singleLinkedList.addFirst(2);
//        singleLinkedList.addFirst(2);
//        singleLinkedList.addFirst(2);
//        System.out.println(singleLinkedList);
//        singleLinkedList.removeValueAll(2);
//        System.out.println(singleLinkedList);
//        System.out.println(singleLinkedList.contains(3));
//        System.out.println(singleLinkedList.contains(6));
//        System.out.println(singleLinkedList.get(2));
//        System.out.println(singleLinkedList.set(2,4));
//        System.out.println(singleLinkedList);
//   }
    //双链表测试
//    public static void main(String[] args){
//        DoubleLink doubleLink = new DoubleLink();
//        doubleLink.addFirst(2);
//        doubleLink.addFirst(3);
//        doubleLink.addFirst(1);
//        doubleLink.addFirst(4);
//        doubleLink.addLast(10);
//        //4->1->3->2->10
//        doubleLink.addIndex(0,5);
//        doubleLink.addIndex(6,100);
//        doubleLink.addIndex(3,20);
//        //5->4->1->20->3->2->10->100
//        System.out.println(doubleLink);
//        System.out.println(doubleLink.get(5));
//        System.out.println(doubleLink.contains(11));
//        System.out.println(doubleLink.contains(20));
//        System.out.println(doubleLink.set(2,50));
//        //5->4->50->20->3->2->10->100
//        System.out.println(doubleLink);
//        doubleLink.removeFirst();
//        doubleLink.removeLast();
//        doubleLink.removeIndex(1);
//        //4->20->3->2->10
//        System.out.println(doubleLink);
//        doubleLink.addIndex(2,2);
//        doubleLink.addIndex(2,2);
//        doubleLink.addIndex(2,2);
//        doubleLink.addIndex(7,2);
//        //4->20->2->2->2->3->2->2->10
//        System.out.println(doubleLink);
//        doubleLink.removeVlaOnce(20);
//        doubleLink.removeVlaOnce(2);
//        //4->2->2->3->2->2->10
//        System.out.println(doubleLink);
//        doubleLink.removeValAll(2);
//        //4->3->10
//        System.out.println(doubleLink);
//    }
    //单链表虚拟头节点
    public static void main(String[] args) {
        SingleLinkedListWithHead sh = new SingleLinkedListWithHead();
        sh.addFirst(1);
        sh.addFirst(3);
        sh.addLast(5);
        sh.addLast(7);
        sh.addLast(9);
        sh.addIndex(2, 10);
        //3->1->10->5->7->9
        System.out.println(sh);
        System.out.println(sh.getVal(3));
        System.out.println(sh.contains(9));
        System.out.println(sh.contains(8));
        System.out.println(sh.setVal(1, 100));
        //3->100->10->5->7->9
        System.out.println(sh);
        sh.removeLast();
        sh.removeFirst();
        sh.removeIndex(1);
        //100->5->7
        System.out.println(sh);
        sh.addIndex(0, 2);
        sh.addIndex(3, 2);
        sh.addIndex(3, 2);
        sh.addIndex(3, 2);
        sh.addLast(2);
        //2->100->5->2->2->2->7->2
        System.out.println(sh);
        sh.removeValOnce(2);
        //100->5->2->2->2->7->2
        System.out.println(sh);
        sh.removeValAll(2);
        //100->5->7
        System.out.println(sh);
    }
}
